from importlib.metadata import entry_points

group_name = "demo.plugins"
plugins = entry_points(group=group_name)

for plugin in plugins:
    try:
        # Load the extension
        entrypoint = plugin.load()
        # Call the entrypoint
        entrypoint()
    except Exception as err:
        raise RuntimeError(
            f"Failed to load the plugin: {plugin.name}. "
        ) from err